package com.ruoyi.framework.config;

import java.time.Duration;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * RestTemplate 统一配置
 * <p>统一超时时间，避免外部接口阻塞线程池。</p>
 */
@Configuration
public class RestTemplateConfig
{
    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder)
    {
        return builder
            .setConnectTimeout(Duration.ofSeconds(10))
            .setReadTimeout(Duration.ofSeconds(10))
            .build();
    }
}
